﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SmartPaginator.Elements;
using System.Windows;

namespace SmartPaginator
{
    public class HarvestResult
    {
        #region Constructor

        public HarvestResult(UIElement element, double remainingHeight)
            : this(element, remainingHeight, false, false)
        { 
        }

        public HarvestResult(UIElement element, double remainingHeight, bool addColumnBreak, bool addPageBreak)
        {
            if (remainingHeight < 0)
                remainingHeight = 0;
                
            HarvestedElement = element;
            RemainingHeight = remainingHeight;

            if (remainingHeight == 0)
                AddColumnBreak = true;
            else
                AddColumnBreak = addColumnBreak;
    
            AddPageBreak = addPageBreak;
        }

        #endregion

        #region Properties

        public double RemainingHeight { get; private set; }

        public UIElement HarvestedElement { get; private set; }

        public bool AddColumnBreak { get; private set; }

        public bool AddPageBreak { get; private set; }

        #endregion

        #region Static Properties

        public static readonly HarvestResult BreakColumn = new HarvestResult(null, 0, true, false);

        public static readonly HarvestResult BreakPage = new HarvestResult(null, 0, true, true);

        #endregion
    }
}
